package com.hualala.controller;

import com.hualala.grpc.message.HelloReply;
import com.hualala.grpc.message.HelloRequest;
import com.hualala.grpc.message.HelloServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



/**
 * @author cheng
 */
@RequestMapping("user")
@RestController
public class UserController {

    @GrpcClient("hello-service")
    private HelloServiceGrpc.HelloServiceBlockingStub blockingStub;


    @GetMapping("hello")
    public String hello(String name) {
        HelloReply helloReply = blockingStub.queryRequest(HelloRequest.newBuilder()
                .setName(name).build());
        return String.format("im %s,%s", name, helloReply.getMessage());
    }
}
